home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / GRAPHICS / COMMON.ZIP / TERM.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-27  |  1.5 KB  |  83 lines

  1. /*
  2.  
  3.    test term program
  4.  
  5.    Copyright 1995, ALec Russell
  6.  
  7.    This WORKS with Alec Russell's serial.c / serio.h stuff.
  8.  
  9. */
  10.  
  11. #include <stdio.h>
  12. #include <bios.h>
  13. #include <io.h>
  14. #include <stdlib.h>
  15. #include <conio.h>
  16. #include <time.h>
  17. #include <alloc.h>
  18. #include <dos.h>
  19. #include <time.h>
  20. #include <string.h>
  21.  
  22. #include "serio.h"
  23.  
  24. /* ---------------------- main() --------------------- September 19,1993 */
  25. void main(void)
  26. {
  27.    int a;
  28.    short done;
  29.    serial_232_t serial_data;
  30.  
  31.    /* setup default parms for com port etc... */
  32.    serial_data.comport=1;
  33.    serial_data.irq=0;
  34.    serial_data.baud=BAUD_9600;
  35.    serial_data.bits=8;
  36.    serial_data.parity=PARITY_NONE;
  37.    serial_data.stops=1;
  38.          
  39.    init_232(&serial_data);
  40.  
  41.    done=0;
  42.    while ( !done )
  43.       {
  44.       if ( char_ready_232() )
  45.          {
  46.          a=get_232();
  47.          printf("%c", a);
  48.  
  49.          switch ( a )
  50.             {
  51.             // put more options here
  52.  
  53.             case '\r':
  54.                printf("\n");
  55.                break;
  56.             }
  57.          }
  58.  
  59.       if ( bioskey(1) )
  60.          {
  61.          a=getch();
  62.          if ( a == 0 )   // Function keys / arrow keys require this code
  63.             a=-getch();
  64.  
  65.          printf("%c", a);
  66.          send_232(a);
  67.  
  68.          switch ( a )
  69.             {
  70.             // put more options here
  71.  
  72.             case ESC:
  73.                done=1;
  74.                break;
  75.             }
  76.          }
  77.       }
  78.  
  79.    deinit_232();
  80. }
  81. /* ------------------ EOF ------------------------------------------ */
  82.  
  83.